function  G = calConstraints(S)

m = size(S,2);
no_constraints = 0;
for i=1:m
    inx_i = find(S(i).yhat);
    if ~isempty(inx_i)
        G(i,inx_i+no_constraints) = 1;        
        no_constraints = no_constraints + sum(inx_i>0);
    end
end
